﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArmoryData.Character
{
    /// <summary>
    /// A collection of <see cref="ArenaTeam"/>s
    /// </summary>
    public class ArenaTeamCollection : System.Collections.ObjectModel.Collection<ArenaTeam>
    {
        /// <summary>
        /// Returns the arena team with the specified size.
        /// </summary>
        /// <param name="size">The size of the desired arena team.</param>
        /// <returns>The arena team with the specified size.</returns>
        public ArenaTeam this[string size] 
        {
            get
            {
                ArenaTeam me = new ArenaTeam() { Name = "null" };
                foreach (ArenaTeam team in Items)
                {
                    if (team.Size.ToString() == size && team.GamesPlayed >= me.GamesPlayed)
                        me = team;
                }
                if (me.Name == "null") me = null;
                return me;
            }
        }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            string ret = "";
            foreach (ArenaTeam team in Items)
            {
                ret += Environment.NewLine + team.Name + Environment.NewLine + "\t\tGames\tWin - Loss\tRating" + Environment.NewLine;
                ret += team.ToString() + Environment.NewLine;
            }
            return ret;
        }
    }
}
